package com.uetoken.cn.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.uetoken.cn.R;
import com.uetoken.cn.bean.CustomMailsBean;

import java.util.List;

/**
 * @author 谢杨
 * @time 2018/7/24 10:16
 * @class 描述:消息中心适配器
 */
public class MessageCenterAdapter extends BaseQuickAdapter<CustomMailsBean,BaseViewHolder> {

    private static final int MODE_CHECK = 0;
    private int mEditMode = MODE_CHECK;

    public MessageCenterAdapter(int layoutResId, @Nullable List<CustomMailsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final CustomMailsBean item) {
        TextView mTvTitle = helper.getView(R.id.tv_item_message_center_title);
        mTvTitle.setText(item.getTitle());
        helper.setText(R.id.tv_item_message_center_time,item.getCreatetime());
        helper.setText(R.id.tv_item_message_center_content,item.getContent());
        ImageView mIvCheckbox = helper.getView(R.id.iv_item_message_center);
        TextView mTvStatus = helper.getView(R.id.iv_item_message_status);
        if (mEditMode==MODE_CHECK){
            mIvCheckbox.setVisibility(View.GONE);
        }else{
            mIvCheckbox.setVisibility(View.VISIBLE);
            if (item.isSelect()){
                mIvCheckbox.setImageResource(R.drawable.ic_single_selection_select);
            }else{
                mIvCheckbox.setImageResource(R.drawable.ic_single_selection_not_select);
            }
        }
        int status = item.getStatus();
        if (status==0){
            //未读状态
            mTvTitle.setTextColor(ContextCompat.getColor(mContext,android.R.color.black));
            mTvStatus.setVisibility(View.VISIBLE);
        }else{
            //已读状态
            mTvTitle.setTextColor(ContextCompat.getColor(mContext,android.R.color.darker_gray));
            mTvStatus.setVisibility(View.INVISIBLE);
        }
    }

    public void setEditMode(int editMode) {
        mEditMode = editMode;
    }

}
